package androidx.transition;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Matrix;
import android.graphics.PointF;
import android.os.Build.VERSION;
import android.util.AttributeSet;
import android.util.Property;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.core.view.ViewCompat;
import o.fx;
import o.mw;
import o.ne;
import o.nf;
import o.ng;
import o.ni;
import o.nm;
import o.nq;
import o.ns;
import o.nx;
import o.oi;
import org.xmlpull.v1.XmlPullParser;

public class ChangeTransform extends Transition {
    private static final Property<d, float[]> ʻ = new Property<d, float[]>(float[].class, "nonTranslations") {
        public /* synthetic */ Object get(Object obj) {
            return ˎ((d) obj);
        }

        public /* synthetic */ void set(Object obj, Object obj2) {
            ॱ((d) obj, (float[]) obj2);
        }

        public float[] ˎ(d dVar) {
            return null;
        }

        public void ॱ(d dVar, float[] fArr) {
            dVar.ˋ(fArr);
        }
    };
    private static final Property<d, PointF> ˋॱ = new Property<d, PointF>(PointF.class, "translations") {
        public /* synthetic */ Object get(Object obj) {
            return ˊ((d) obj);
        }

        public /* synthetic */ void set(Object obj, Object obj2) {
            ॱ((d) obj, (PointF) obj2);
        }

        public PointF ˊ(d dVar) {
            return null;
        }

        public void ॱ(d dVar, PointF pointF) {
            dVar.ॱ(pointF);
        }
    };
    private static final boolean ˏॱ;
    private static final String[] ᐝ = new String[]{"android:changeTransform:matrix", "android:changeTransform:transforms", "android:changeTransform:parentMatrix"};
    private Matrix ˊॱ = new Matrix();
    boolean ˋ = true;
    private boolean ͺ = true;

    static class b {
        final float ʼ;
        final float ˊ;
        final float ˋ;
        final float ˎ;
        final float ˏ;
        final float ॱ;
        final float ॱॱ;
        final float ᐝ;

        b(View view) {
            this.ˋ = view.getTranslationX();
            this.ˊ = view.getTranslationY();
            this.ˎ = ViewCompat.ͺ(view);
            this.ˏ = view.getScaleX();
            this.ॱ = view.getScaleY();
            this.ʼ = view.getRotationX();
            this.ॱॱ = view.getRotationY();
            this.ᐝ = view.getRotation();
        }

        public void ˏ(View view) {
            ChangeTransform.ˋ(view, this.ˋ, this.ˊ, this.ˎ, this.ˏ, this.ॱ, this.ʼ, this.ॱॱ, this.ᐝ);
        }

        public boolean equals(Object obj) {
            if (!(obj instanceof b)) {
                return false;
            }
            b bVar = (b) obj;
            if (bVar.ˋ == this.ˋ && bVar.ˊ == this.ˊ && bVar.ˎ == this.ˎ && bVar.ˏ == this.ˏ && bVar.ॱ == this.ॱ && bVar.ʼ == this.ʼ && bVar.ॱॱ == this.ॱॱ && bVar.ᐝ == this.ᐝ) {
                return true;
            }
            return false;
        }

        public int hashCode() {
            int floatToIntBits;
            int i = 0;
            int floatToIntBits2 = (this.ˋ != 0.0f ? Float.floatToIntBits(this.ˋ) : 0) * 31;
            if (this.ˊ != 0.0f) {
                floatToIntBits = Float.floatToIntBits(this.ˊ);
            } else {
                floatToIntBits = 0;
            }
            floatToIntBits2 = (floatToIntBits + floatToIntBits2) * 31;
            if (this.ˎ != 0.0f) {
                floatToIntBits = Float.floatToIntBits(this.ˎ);
            } else {
                floatToIntBits = 0;
            }
            floatToIntBits2 = (floatToIntBits + floatToIntBits2) * 31;
            if (this.ˏ != 0.0f) {
                floatToIntBits = Float.floatToIntBits(this.ˏ);
            } else {
                floatToIntBits = 0;
            }
            floatToIntBits2 = (floatToIntBits + floatToIntBits2) * 31;
            if (this.ॱ != 0.0f) {
                floatToIntBits = Float.floatToIntBits(this.ॱ);
            } else {
                floatToIntBits = 0;
            }
            floatToIntBits2 = (floatToIntBits + floatToIntBits2) * 31;
            if (this.ʼ != 0.0f) {
                floatToIntBits = Float.floatToIntBits(this.ʼ);
            } else {
                floatToIntBits = 0;
            }
            floatToIntBits2 = (floatToIntBits + floatToIntBits2) * 31;
            if (this.ॱॱ != 0.0f) {
                floatToIntBits = Float.floatToIntBits(this.ॱॱ);
            } else {
                floatToIntBits = 0;
            }
            floatToIntBits = (floatToIntBits + floatToIntBits2) * 31;
            if (this.ᐝ != 0.0f) {
                i = Float.floatToIntBits(this.ᐝ);
            }
            return floatToIntBits + i;
        }
    }

    static class c extends nq {
        private nf ˊ;
        private View ˎ;

        c(View view, nf nfVar) {
            this.ˎ = view;
            this.ˊ = nfVar;
        }

        public void ˋ(@NonNull Transition transition) {
            transition.ॱ(this);
            ni.ॱ(this.ˎ);
            this.ˎ.setTag(o.nn.c.ʽ, null);
            this.ˎ.setTag(o.nn.c.ˋ, null);
        }

        public void ˊ(@NonNull Transition transition) {
            this.ˊ.setVisibility(4);
        }

        public void ˏ(@NonNull Transition transition) {
            this.ˊ.setVisibility(0);
        }
    }

    static class d {
        private final View ˊ;
        private float ˋ;
        private float ˎ;
        private final Matrix ˏ = new Matrix();
        private final float[] ॱ;

        d(View view, float[] fArr) {
            this.ˊ = view;
            this.ॱ = (float[]) fArr.clone();
            this.ˋ = this.ॱ[2];
            this.ˎ = this.ॱ[5];
            ˎ();
        }

        void ˋ(float[] fArr) {
            System.arraycopy(fArr, 0, this.ॱ, 0, fArr.length);
            ˎ();
        }

        void ॱ(PointF pointF) {
            this.ˋ = pointF.x;
            this.ˎ = pointF.y;
            ˎ();
        }

        private void ˎ() {
            this.ॱ[2] = this.ˋ;
            this.ॱ[5] = this.ˎ;
            this.ˏ.setValues(this.ॱ);
            oi.ˋ(this.ˊ, this.ˏ);
        }

        Matrix ॱ() {
            return this.ˏ;
        }
    }

    static {
        boolean z = true;
        if (VERSION.SDK_INT < 21) {
            z = false;
        }
        ˏॱ = z;
    }

    public ChangeTransform(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, ns.ॱॱ);
        this.ˋ = fx.ˏ(obtainStyledAttributes, (XmlPullParser) attributeSet, "reparentWithOverlay", 1, true);
        this.ͺ = fx.ˏ(obtainStyledAttributes, (XmlPullParser) attributeSet, "reparent", 0, true);
        obtainStyledAttributes.recycle();
    }

    public String[] ˋ() {
        return ᐝ;
    }

    private void ˏ(nx nxVar) {
        View view = nxVar.ॱ;
        if (view.getVisibility() != 8) {
            Object obj;
            nxVar.ˊ.put("android:changeTransform:parent", view.getParent());
            nxVar.ˊ.put("android:changeTransform:transforms", new b(view));
            Matrix matrix = view.getMatrix();
            if (matrix == null || matrix.isIdentity()) {
                obj = null;
            } else {
                obj = new Matrix(matrix);
            }
            nxVar.ˊ.put("android:changeTransform:matrix", obj);
            if (this.ͺ) {
                matrix = new Matrix();
                ViewGroup viewGroup = (ViewGroup) view.getParent();
                oi.ˊ(viewGroup, matrix);
                matrix.preTranslate((float) (-viewGroup.getScrollX()), (float) (-viewGroup.getScrollY()));
                nxVar.ˊ.put("android:changeTransform:parentMatrix", matrix);
                nxVar.ˊ.put("android:changeTransform:intermediateMatrix", view.getTag(o.nn.c.ʽ));
                nxVar.ˊ.put("android:changeTransform:intermediateParentMatrix", view.getTag(o.nn.c.ˋ));
            }
        }
    }

    public void ˋ(@NonNull nx nxVar) {
        ˏ(nxVar);
        if (!ˏॱ) {
            ((ViewGroup) nxVar.ॱ.getParent()).startViewTransition(nxVar.ॱ);
        }
    }

    public void ॱ(@NonNull nx nxVar) {
        ˏ(nxVar);
    }

    public Animator ˋ(@NonNull ViewGroup viewGroup, nx nxVar, nx nxVar2) {
        if (nxVar == null || nxVar2 == null || !nxVar.ˊ.containsKey("android:changeTransform:parent") || !nxVar2.ˊ.containsKey("android:changeTransform:parent")) {
            return null;
        }
        boolean z;
        ViewGroup viewGroup2 = (ViewGroup) nxVar.ˊ.get("android:changeTransform:parent");
        ViewGroup viewGroup3 = (ViewGroup) nxVar2.ˊ.get("android:changeTransform:parent");
        if (!this.ͺ || ˋ(viewGroup2, viewGroup3)) {
            z = false;
        } else {
            z = true;
        }
        Matrix matrix = (Matrix) nxVar.ˊ.get("android:changeTransform:intermediateMatrix");
        if (matrix != null) {
            nxVar.ˊ.put("android:changeTransform:matrix", matrix);
        }
        matrix = (Matrix) nxVar.ˊ.get("android:changeTransform:intermediateParentMatrix");
        if (matrix != null) {
            nxVar.ˊ.put("android:changeTransform:parentMatrix", matrix);
        }
        if (z) {
            ॱ(nxVar, nxVar2);
        }
        Animator ॱ = ॱ(nxVar, nxVar2, z);
        if (z && ॱ != null && this.ˋ) {
            ˎ(viewGroup, nxVar, nxVar2);
        } else if (!ˏॱ) {
            viewGroup2.endViewTransition(nxVar.ॱ);
        }
        return ॱ;
    }

    private ObjectAnimator ॱ(nx nxVar, nx nxVar2, boolean z) {
        Matrix matrix;
        Matrix matrix2 = (Matrix) nxVar.ˊ.get("android:changeTransform:matrix");
        Matrix matrix3 = (Matrix) nxVar2.ˊ.get("android:changeTransform:matrix");
        if (matrix2 == null) {
            matrix2 = ng.ˎ;
        }
        if (matrix3 == null) {
            matrix = ng.ˎ;
        } else {
            matrix = matrix3;
        }
        if (matrix2.equals(matrix)) {
            return null;
        }
        final b bVar = (b) nxVar2.ˊ.get("android:changeTransform:transforms");
        final View view = nxVar2.ॱ;
        ॱ(view);
        r1 = new float[9];
        matrix2.getValues(r1);
        float[] fArr = new float[9];
        matrix.getValues(fArr);
        final d dVar = new d(view, r1);
        PropertyValuesHolder ofObject = PropertyValuesHolder.ofObject(ʻ, new ne(new float[9]), new float[][]{r1, fArr});
        PropertyValuesHolder ˏ = nm.ˏ(ˋॱ, ˋॱ().ˏ(r1[2], r1[5], fArr[2], fArr[5]));
        Animator ofPropertyValuesHolder = ObjectAnimator.ofPropertyValuesHolder(dVar, new PropertyValuesHolder[]{ofObject, ˏ});
        final boolean z2 = z;
        Object anonymousClass5 = new AnimatorListenerAdapter(this) {
            final /* synthetic */ ChangeTransform ʻ;
            private Matrix ॱॱ = new Matrix();
            private boolean ᐝ;

            public void onAnimationCancel(Animator animator) {
                this.ᐝ = true;
            }

            public void onAnimationEnd(Animator animator) {
                if (!this.ᐝ) {
                    if (z2 && this.ʻ.ˋ) {
                        ॱ(matrix);
                    } else {
                        view.setTag(o.nn.c.ʽ, null);
                        view.setTag(o.nn.c.ˋ, null);
                    }
                }
                oi.ˋ(view, null);
                bVar.ˏ(view);
            }

            public void onAnimationPause(Animator animator) {
                ॱ(dVar.ॱ());
            }

            public void onAnimationResume(Animator animator) {
                ChangeTransform.ॱ(view);
            }

            private void ॱ(Matrix matrix) {
                this.ॱॱ.set(matrix);
                view.setTag(o.nn.c.ʽ, this.ॱॱ);
                bVar.ˏ(view);
            }
        };
        ofPropertyValuesHolder.addListener(anonymousClass5);
        mw.ˊ(ofPropertyValuesHolder, anonymousClass5);
        return ofPropertyValuesHolder;
    }

    private boolean ˋ(ViewGroup viewGroup, ViewGroup viewGroup2) {
        if (ˎ(viewGroup) && ˎ(viewGroup2)) {
            nx ˎ = ˎ(viewGroup, true);
            if (ˎ == null) {
                return false;
            }
            if (viewGroup2 != ˎ.ॱ) {
                return false;
            }
            return true;
        } else if (viewGroup == viewGroup2) {
            return true;
        } else {
            return false;
        }
    }

    private void ˎ(ViewGroup viewGroup, nx nxVar, nx nxVar2) {
        View view = nxVar2.ॱ;
        Matrix matrix = new Matrix((Matrix) nxVar2.ˊ.get("android:changeTransform:parentMatrix"));
        oi.ॱ(viewGroup, matrix);
        nf ॱ = ni.ॱ(view, viewGroup, matrix);
        if (ॱ != null) {
            Transition transition;
            ॱ.ˏ((ViewGroup) nxVar.ˊ.get("android:changeTransform:parent"), nxVar.ॱ);
            while (transition.ॱ != null) {
                transition = transition.ॱ;
            }
            transition.ˊ(new c(view, ॱ));
            if (ˏॱ) {
                if (nxVar.ॱ != nxVar2.ॱ) {
                    oi.ˋ(nxVar.ॱ, 0.0f);
                }
                oi.ˋ(view, 1.0f);
            }
        }
    }

    private void ॱ(nx nxVar, nx nxVar2) {
        Matrix matrix;
        Matrix matrix2 = (Matrix) nxVar2.ˊ.get("android:changeTransform:parentMatrix");
        nxVar2.ॱ.setTag(o.nn.c.ˋ, matrix2);
        Matrix matrix3 = this.ˊॱ;
        matrix3.reset();
        matrix2.invert(matrix3);
        matrix2 = (Matrix) nxVar.ˊ.get("android:changeTransform:matrix");
        if (matrix2 == null) {
            matrix2 = new Matrix();
            nxVar.ˊ.put("android:changeTransform:matrix", matrix2);
            matrix = matrix2;
        } else {
            matrix = matrix2;
        }
        matrix.postConcat((Matrix) nxVar.ˊ.get("android:changeTransform:parentMatrix"));
        matrix.postConcat(matrix3);
    }

    static void ॱ(View view) {
        ˋ(view, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f);
    }

    static void ˋ(View view, float f, float f2, float f3, float f4, float f5, float f6, float f7, float f8) {
        view.setTranslationX(f);
        view.setTranslationY(f2);
        ViewCompat.ˏ(view, f3);
        view.setScaleX(f4);
        view.setScaleY(f5);
        view.setRotationX(f6);
        view.setRotationY(f7);
        view.setRotation(f8);
    }
}
